package socket3;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class ClientDemo {
	public static void main(String[] args) {
		try {
			Socket socket=new Socket("192.168.1.115", 8899);
			System.out.println("已连接上服务器");
			Scanner in=new Scanner(System.in);
			String message;
			ObjectOutputStream out=new ObjectOutputStream(socket.getOutputStream());
			do{
				message=in.nextLine();
				out.writeObject(message);
				out.flush();
			}while(!message.equals("bye"));
			in.close();socket.close();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
}